package main

import (
	"encoding/json"
	"gitee.com/zjzhang/log"
	. "gitee.com/zjzhang/weixin"
	"io/ioutil"
)

// 微信公众平台测试号
// http://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index
// 测试号 毛毛雨
const (
	originId       = "gh_34440c5119c6"
	appId          = "wx29b376d2cda8e09c"
	appSecret      = "bacdeabe938d7bc15c2dcf317e243b33"
	token          = "0t37dWsIYg6NsVLgEY1fNuB1rSLyyeQE"
	encodingAESKey = "dkVSmV3CtG3IBCY96A8RSNoCOzaPcx36uGJo8fl9wWn" // 为了通过验证
)

type AppConfig struct {
	ListenAddr 		string	`json:"listen_addr,omitempty"`
	ListenPort 		string	`json:"listen_port,omitempty"`
	ListenPath 		string	`json:"listen_path,omitempty"`
	AppAccessTokenURL	string	`json:"app_accesstoken_url,omitempty"`
	AppOrigin 		string	`json:"app_origin,omitempty"`
	AppID 			string	`json:"app_id,omitempty"`
	AppSecret 		string	`json:"app_secret,omitempty"`
	AppToken 		string	`json:"app_token,omitempty"`
	AppAESKey 		string	`json:"app_aeskey,omitempty"`
	SocketIoURL 		string	`json:"cs_socketio,omitempty"`
	UploadURL 		string	`json:"cs_upload_url,omitempty"`
	UploadParam 	string	`json:"cs_upload_param,omitempty"`
	UploadPrefix 	string	`json:"cs_upload_prefix,omitempty"`
	BaiduASR 		string	`json:"baiduasr_url,omitempty"`
}

var Config =&AppConfig{}

func init()  {
	data, err  := ioutil.ReadFile("config.json")
	if err != nil {
		log.Fatal("打开配置文件失败",err)
	}
	err = json.Unmarshal(data, Config)
	if err != nil {
		log.Fatal("解析配置文件失败",err)
	}
	//log.Debug(Config)
}

var (
	buttons = []Button{
		Button{
			Name: "扫码",
			SubButton: []Button{
				Button{
					Name: "扫码带提示",
					Type: MenuTypeScancodeWaitmsg,
					Key:  "rselfmenu_0_0",
				},
				Button{
					Name: "扫码推事件",
					Type: MenuTypeScancodePush,
					Key:  "rselfmenu_0_1",
				},
			},
		},
		Button{
			Name: "发图",
			SubButton: []Button{
				Button{
					Name: "系统拍照发图",
					Type: MenuTypePicSysphoto,
					Key:  "rselfmenu_1_0",
				},
				Button{
					Name: "拍照或者相册发图",
					Type: MenuTypePicPhotoOrAlbum,
					Key:  "rselfmenu_1_1",
				},
				Button{
					Name: "微信相册发图",
					Type: MenuTypePicWeixin,
					Key:  "rselfmenu_1_2",
				},
			},
		},
		Button{
			Name: "测试",
			SubButton: []Button{
				Button{
					Name: "客服",
					Type: MenuTypeClick,
					Key:  "/客服",
				},
				Button{
					Name: "测试页面",
					Type: MenuTypeView,
					URL:  "https://wx.touchiot.top/weixin/static/",
				},
				Button{
					Name: "发送位置",
					Type: MenuTypeLocationSelect,
					Key:  "rselfmenu_2_0",
				},
			},
		},
	}
)
